package threading;

import java.util.concurrent.Semaphore;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2022-10-07
 * Time: 8:34
 */
public class demo1 {
    public static void main(String[] args) throws InterruptedException {
        //构造的时候需要指定初始值，也就是计数器的初始值
        Semaphore  semaphore=new Semaphore(4);
        //这是P操作，申请资源，计数器+1
        semaphore.acquire();
        //这是V操作，释放资源，计数器-1
        semaphore.release();


    }
}
